perm filename PINK.1[HAK,ROB] blob sn#436095 filedate 1979-04-21 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00005 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002		TITLE PINK
C00005 00003	GETINFO JOBPNT SETUP
C00009 00004	ALLWHO ALLWH1 ASExit NotRJob GotPerson GotFantom GotSegment ADDREC SUBREC SUBRE1
C00015 00005	START
C00017 ENDMK
C⊗;
	TITLE PINK

; see also WHOPHN.FAI[S,MRC]

; ac definitions
AC1 ← 1;
AC2 ← 2;
AC3 ← 3;
AC4 ← 4;
AC5 ← 5;
P ← 17;
PDLEN←←40	;

; offsets into system table
SYSTAB←←400000	; The system table will be mapped as an upper segment
JBTSTS←←210	; job status table
PRJPRG←←211	; prj,prg name (sixbit) table
JOBNAM←←225	; job name table
MAXJOB←←222	; highest job number possible

; Masks for left half of words returned by a JBTSTS UUO.
RealJob	←← 40000	; The job is either a person, phantom, or segment
LogdIn	←← 10000	; The job is logged in, so it is a real person
IsSeg	←←  1000	; The job is a segment

	SET	JobRec,0	; Job Info Record Definition
	USE	JobRec
J.Next::BLOCK	1	; Link to next record
J.JobN::BLOCK	1	; Job number of this record
J.PPN::	BLOCK	1	; Sixbit PPN for this job
J.JNam::BLOCK	1	; Sixbit Job Name for this job
J.Stat::BLOCK	1	; Status word (from JBTSTS) for this job
J.TTY:: BLOCK	1	; Controlling TTY for this job
JLength ←← .		; Length of this record
	USE

PerLst:	BLOCK	JLength		; dummy listhead for Person list
FanLst:	BLOCK	JLength		; dummy listhead of Phantom list
SegLst:	BLOCK	JLength		; dummy listhead of Segment list
RecBuf:	BLOCK 	JLength*=64	; Storage for Job Info Records

PDLPTR:	IOWD	PDLEN,PDL
PDL:	BLOCK	PDLEN
;GETINFO JOBPNT SETUP

; GetInfo(jobrec,jobnum)	; fill a job record with info about a job
;   This procedure will fill all the fields (except the link words) of a
;   job record with information on a specified job.
;
; INPUTS:
;   AC1:	pointer to record to recieve the data
;   AC2:	job number of job in question
; REGISTER USAGE:
;   AC1:	General usage - offset into system tables
;   AC2:	job # under consideration
;   AC3:	pointer to the record to get the data
;
GETINFO:
	PUSH	P,AC1
	PUSH	P,AC3
	MOVE	AC3,AC1		; Save the pointer to the record
;	SETZM	J.Next(AC3)	; zero the link word
	MOVEM	AC2,J.JobN(AC3)	; get the job # for this record
	MOVEI	AC1,PRJPRG	; get the PRJ,PRG for this job
	PUSHJ	P,JOBPNT
	MOVEM	AC1,J.PPN(AC3)
	MOVEI	AC1,JBTSTS	; get the job status for this job
	PUSHJ	P,JOBPNT
	MOVEM	AC1,J.Stat(AC3)
	MOVEI	AC1,JOBNAM	; get the job name for this job
	PUSHJ	P,JOBPNT
	MOVEM	AC1,J.JNam(AC3)
	POP	P,AC3
	POP	P,AC1
	POPJ	P,

; JobPnt(TablePointer,JobNum)
;    This routine will return the dataum from a table of job information of some
;    specific type.  For exapmle, if AC1 contains 211, and AC2 contains 5, then
;    a the PRJPRG for job 5 is returned in AC1.
;    ** This routine assumes the system table has been mapped into high core via
;    a SETPR2 call **.
;
; INPUTS:
;   AC1:	offset into system table pointer to job table info
;   AC2:	current job number
; OUTPUTS:
;   AC1:	job table information
;
JOBPNT:
	MOVE AC1,STSTAB(AC1)	; fetch pointer to table in ac1
	ADD  AC1,AC2		; make index into table
	MOVE AC1,SYSTAB(AC1)	; fetch the data from the table
	POPJ P,			; and return

; SetUp
;   Maps the job tables as an upper segment (starting at 400000)
;   Gotta call this routine before trying to do any of the above
;   routines.
;
SETUP:				; map the job low core as an upper segment
	PUSH P,AC1
	MOVSI AC1,377777
	SETPR2 AC1,
	HALT			; error return - help!
	POP P,AC1
	POPJ P,

;ALLWHO ALLWH1 ASExit NotRJob GotPerson GotFantom GotSegment ADDREC SUBREC SUBRE1

; AllWho - get the info on all jobs, split into people, fantoms, segments
;
; This routine fills records with raw data on all jobs, from job 0 to the highest 
; possible job.  The individual records are split into three lists, one for
; jobs that are associated with Real People, one for jobs that are Phantoms, and
; one for jobs that are naught but some poor luser's upper Segment.
;
; register usage:
;   AC1		current record under consideration
;   AC2		current job #
;   AC3		general - Job Status.
;
ALLWHO:
	PUSH	P,AC1		;
	PUSH	P,AC2		;
	PUSH	P,AC3

	PUSHJ	P,SETUP		; setup system tables as upper segment
	SETZM	PerLst		; clear the linked lists
	SETZM	FanLst		;
	SETZM	SegLst		;
	MOVEI	AC1,RecBuf	; start with first record in RecBuf
	SETZM	AC2		; start with job 0
ALLWH1:
	PUSHJ	P,GetInfo	; get a record's worth of info on this job
	MOVE	AC3,J.Stat(AC1)	; fetch job status
	TLNN	AC3,RealJob	; is it a job at all?
	JRST	NotRJob		;   no - let's ignore it
	TLNE	AC3,IsSeg	; is it an upper segment?
	JRST	GotSegment	;   yep - 
	TLNE	AC3,LogdIn	; is it logged in?
	JRST	GotPerson	;  yes, it's a real live human
	JRST	GotFantom	;  nope, must be a phantom

ASExit:				; exit routine for all the above
	ADDI	AC1,JLength	; get pointer to next free record in RECBUF
	ADDI	AC2,1		; look at next job
	CAMG	AC2,SYSTAB+MAXJOB	;
	JRST	ALLWH1		; loop until highest possible job

	POP	P,AC3		;
	POP	P,AC2		;
	POP	P,AC1		;
	POPJ	P,		;

;
; These routines are all entered with AC1 pointing to the current record.
; Exit these routines via a JRST ASExit.
;
NotRJob:		; not a a job at all
	JRST	ASExit
GotPerson:		; this job is a real person
	PUSH	P,AC2
	MOVEI	AC2,PerLst	;
	PUSHJ	P,AddRec	; put this record on the Person List
	POP	P,AC2
	JRST	ASExit
GotFantom:		; this job is a phantom
	PUSH	P,AC2
	MOVEI	AC2,FanLst	;
	PUSHJ	P,AddRec	; put this record on the Person List
	POP	P,AC2
	JRST	ASExit
GotSegment:		; this job slot is senselessly taken by an upper segment
	PUSH	P,AC2
	MOVEI	AC2,SegLst	;
	PUSHJ	P,AddRec	; put this record on the Person List
	POP	P,AC2
	JRST	ASExit

;AddRec
; Insert a record at the head of the specified list.
; INPUTS:
;   AC1		pointer to record to be added
;   AC2		pointer to list head of list to add to
;
ADDREC:
	PUSH	P,AC3
	MOVE	AC3,J.Next(AC2)	; get pointer to next on list
	MOVEM	AC1,J.Next(AC2)	; point list to new record to be added
	MOVEM	AC3,J.Next(AC1)	; point Next(new) at old
	POP	P,AC3
	POPJ	P,

;SubRec
; removes a record from the head of the specified linked list.
; INPUTS:
;   AC1		pointer to list head of list to take from
; OUTPUTS:
;   AC1		pointer to newly removed record (=0 if none left)
;
SUBREC:
	PUSH	P,AC2
	PUSH	P,AC3
	MOVE	AC2,J.Next(AC1)	; get pointer to the record we are gonna take
	JUMPE	AC2,SUBRE1	; if 0, then no record available
	MOVE	AC3,J.Next(AC2)	; get pointer to any remaining sublist
	MOVEM	AC3,J.Next(AC1)	; point listhead at resulting sublist
SUBRE1:	MOVE	AC1,AC2		; well, we said we return the result in AC1
	POP	P,AC3
	POP	P,AC2
	POPJ	P,

;START

START:
	MOVE	P,pdlptr	;
	PUSHJ	P,AllWho	; Get data on all people, fantoms, and segments
	EXIT

	END 	START